﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using EAF.Utility;

namespace App.DTO
{
    /// <summary>
    /// Dto请求实体基类
    /// <typeparam name="TId">id列类型</typeparam>
    /// </summary> 
    public class DtoReqBase<TId>
    {
        /// <summary>
        /// 编号 添加时不用传
        /// </summary> 
        [Display(Name = "编号")]
        public virtual TId Id { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        [Display(Name = "描述")]
        public virtual string Description { get; set; }
        /// <summary>
        /// 排序码
        /// </summary>
        [Display(Name = "排序码")]
        public virtual int? SortNo { get; set; }
        /// <summary>
        /// 是否有效
        /// </summary>
        [Display(Name = "是否有效")]
        public virtual bool Valid { get; set; }
        /// <summary>
        /// 数据版本 业务中无需显示更新用
        /// </summary>
        [Display(Name = "数据版本")]
        public virtual int Version { get; set; } = 0;
    }

    /// <summary>
    /// Dto分页请求实体基类
    /// </summary>
    public class DtoPageReqBase
    {
        /// <summary>
        /// 页码 默认1
        /// </summary>
        [Display(Name = "页码")]
        public int pageIndex { get; set; } = 1;

        /// <summary>
        /// 每页条数 默认5
        /// </summary>
        [Display(Name = "每页条数")]
        public int pageSize { get; set; } = AppConfig.DefaultPageSize;

        /// <summary>
        /// 高级过滤条件 介绍：http://freesql.net/select.html#特别介绍-wheredynamicfilter
        /// </summary>
        [Display(Name = "高级过滤条件")]
        public string whereDynamicFilter { get; set; }

        /// <summary>
        /// 排序字段 如：id asc
        /// </summary>
        [Display(Name = "排序字段")]
        public string orderBy { get; set; }

        /// <summary>
        /// 显示模式 1显示非删除 2显示所有 3显示已删除 默认1
        /// </summary>
        [Display(Name = "显示模式")]
        public ShowMode showMode { get; set; } = ShowMode.Normal;
    }

    /// <summary>
    /// Dto响应实体基类
    /// </summary>
    /// <typeparam name="TId">id列类型</typeparam>
    public class DtoRespBase<TId>
    {
        /// <summary>
        /// 编号
        /// </summary>
        [Display(Name = "编号")]
        public virtual TId Id { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        [Display(Name = "描述")]
        public virtual string Description { get; set; }
        /// <summary>
        /// 排序数字
        /// </summary>
        [Display(Name = "排序数字")]
        public virtual int? SortNo { get; set; }
        /// <summary>
        /// 创建者ID
        /// </summary>
        [Display(Name = "创建者ID")]
        public virtual int? CreaterId { get; set; }
        /// <summary>
        /// 创建人名
        /// </summary>
        [Display(Name = "创建人名")]
        public virtual string CreaterName { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public virtual DateTime CreateTime { get; set; }
        /// <summary>
        /// 修改时间
        /// </summary>
        [Display(Name = "修改时间")]
        public virtual DateTime? UpdateTime { get; set; }
        /// <summary>
        /// 是否有效
        /// </summary>
        [Display(Name = "是否有效")]
        public virtual bool Valid { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Display(Name = "是否删除")]
        public virtual bool Deleted { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        [Display(Name = "删除时间")]
        public virtual DateTime? DeleteTime { get; set; }
        /// <summary>
        /// 数据版本 业务中无需显示更新用
        /// </summary>
        [Display(Name = "数据版本")]
        public virtual int Version { get; set; } = 0;
    }

    /// <summary>
    /// 显示模式
    /// </summary>
    public enum ShowMode
    {
        [Description("显示非删除")]
        Normal = 1,
        [Description("显示所有")]
        All = 2,
        [Description("3显示已删除")]
        Deleted = 3
    }


}
